/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.lnu.ums.dal.impl;

import edu.lnu.ums.dal.IExpenditure;
import edu.lnu.ums.entities.Expenditures;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

/**
 *
 * @author Orysia
 */

@Stateless
public class ExpenditureDAO extends AbstractNoConcurrentAccessGenericDAO<Expenditures> implements IExpenditure {

    public ExpenditureDAO() {
        super(Expenditures.class);
    }

    @Override
    public void delete(Expenditures obj) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public String getOrderByQuery() {
        return "";
    }

    @SuppressWarnings("unchecked")
    public List<Expenditures> getAllByYear(EntityManagerFactory factory, String year, Long procId) {
        EntityManager em = factory.createEntityManager();
        List<Expenditures> result = em.createQuery("from Expenditures where years="+year+" and expparent="+procId).getResultList();
        em.close();
        setEntityManagerFactoryToEntityList(factory, result);
        return result;
    }
    

}
